package org.rcgwt.client.ui.grid.internal;

import org.rcgwt.client.ui.grid.IIndexList;
import org.rcgwt.client.ui.grid.event.IIndexesState;

/**
 * 
 * @author Olivier Oeuillot
 * 
 */
public class IndexesState implements IIndexesState {

    private final IIndexList currentSelectedRows;

    private final IIndexList newSelectedRows;

    private final IIndexList unselectedRows;

    public IndexesState(IIndexList currentSelectedRows,
            IIndexList newSelectedRows, IIndexList unselectedRows) {

        assert currentSelectedRows != null : "CurrentSelectedRows is null !";
        assert newSelectedRows != null : "CurrentSelectedRows is null !";
        assert unselectedRows != null : "CurrentSelectedRows is null !";

        this.currentSelectedRows = currentSelectedRows;
        this.newSelectedRows = newSelectedRows;
        this.unselectedRows = unselectedRows;
    }

    @Override
    public IIndexList getAddedRows() {
        return newSelectedRows;
    }

    @Override
    public IIndexList getRemovedRows() {
        return unselectedRows;
    }

    @Override
    public IIndexList getCurrentRows() {
        return currentSelectedRows;
    }

    @Override
    public String toString() {
        return "[SelectionState newSelected=" + newSelectedRows
                + " unSelected=" + unselectedRows + " currentSelected="
                + getCurrentRows() + "]";
    }
}
